<?php

/**
 * Created by PhpStorm
 * User: 林振宇
 * Date: 2020/8/12
 * Time: 17:40
 */

namespace app\api\controller;

use app\admin\model\Order as OrderModel;
use app\api\service\IndexService;
use app\common\enum\OrderEnum;

class Index extends Base
{

    //首页商品列表
    public function getProduct()
    {
        $data = (new IndexService())->getProduct();
        $this->success('success', $data);
    }

    //商品详情
    public function productDetails($id)
    {
        $data = (new IndexService())->productDetails($id);
        $this->success('success', $data);
    }


    //船只标签
    public function getVesselType()
    {
        $data = (new IndexService())->getVesselType();
        $this->success('success', $data);
    }

    //船源列表
    public function getProductById($id)
    {
        $data = (new IndexService())->getProductById($id);
        $this->success('success', $data);
    }

    //轮询
    public function is_read()
    {
        $where['status'] = OrderEnum::TK_PROGRESS;// 退款中
        $where['is_read'] = OrderEnum::NOT_READ; //未阅读
        $count = (new OrderModel())->where($where)->count();
        if ($count > 0) {
         $this->success('success',true);
        }
        $this->success('success',false);
    }
}
